package com.mk.settlement.model;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Order {
	
	/**
	 * 'orderid':'10001'
	 * 'hotelid':'5'
	 * 'hotelname':'万豪酒店'
	 * 'hprice':'99.99'
	 * 'otaid':'9'
	 * 'otaname':'携程'
	 * 'oprice':'88.88'
	 * 'saletype':'11' //例如：今日特价酒店
	 * 'paytype':'1' //1 预付 2到付
	 */
	
	private Long orderid;
	private Long hotelid ;
	private String hotelname ;
	private Long otaid ;
	private String otaname ;
	private BigDecimal hprice ;
	private BigDecimal oprice ;
	private Integer saletype ;
	private Date checkouttime ;
	private String sDate;
	
	private int payType;
	
	/**
	 * @return the payType
	 */
	public int getPayType() {
		return payType;
	}

	/**
	 * @param payType the payType to set
	 */
	public void setPayType(int payType) {
		this.payType = payType;
	}

	public Order() {
		super();
		// TODO Auto-generated constructor stub
	}
	
	public Order(Long orderid, Long hotelid, String hotelname, Long otaid,
			String otaname, BigDecimal hprice, BigDecimal oprice,
			Integer saletype) {
		super();
		this.orderid = orderid;
		this.hotelid = hotelid;
		this.hotelname = hotelname;
		this.otaid = otaid;
		this.otaname = otaname;
		this.hprice = hprice;
		this.oprice = oprice;
		this.saletype = saletype;
	}
	
	/**
	 * @return the orderid
	 */
	public Long getOrderid() {
		return orderid;
	}

	/**
	 * @param orderid the orderid to set
	 */
	public void setOrderid(Long orderid) {
		this.orderid = orderid;
	}

	/**
	 * @return the hotelid
	 */
	public Long getHotelid() {
		return hotelid;
	}

	/**
	 * @param hotelid the hotelid to set
	 */
	public void setHotelid(Long hotelid) {
		this.hotelid = hotelid;
	}

	/**
	 * @return the hotelname
	 */
	public String getHotelname() {
		return hotelname;
	}

	/**
	 * @param hotelname the hotelname to set
	 */
	public void setHotelname(String hotelname) {
		this.hotelname = hotelname;
	}

	/**
	 * @return the otaid
	 */
	public Long getOtaid() {
		return otaid;
	}

	/**
	 * @param otaid the otaid to set
	 */
	public void setOtaid(Long otaid) {
		this.otaid = otaid;
	}

	/**
	 * @return the otaname
	 */
	public String getOtaname() {
		return otaname;
	}

	/**
	 * @param otaname the otaname to set
	 */
	public void setOtaname(String otaname) {
		this.otaname = otaname;
	}

	/**
	 * @return the hprice
	 */
	public BigDecimal getHprice() {
		return hprice;
	}

	/**
	 * @param hprice the hprice to set
	 */
	public void setHprice(BigDecimal hprice) {
		this.hprice = hprice;
	}

	/**
	 * @return the oprice
	 */
	public BigDecimal getOprice() {
		return oprice;
	}

	/**
	 * @param oprice the oprice to set
	 */
	public void setOprice(BigDecimal oprice) {
		this.oprice = oprice;
	}

	/**
	 * @return the saletype
	 */
	public Integer getSaletype() {
		return saletype;
	}

	/**
	 * @param saletype the saletype to set
	 */
	public void setSaletype(Integer saletype) {
		this.saletype = saletype;
	}
	
	/**
	 * @return the checkouttime
	 */
	public Date getCheckouttime() {
		return checkouttime;
	}

	/**
	 * @param checkouttime the checkouttime to set
	 */
	public void setCheckouttime(Date checkouttime) {
		this.checkouttime = checkouttime;
	}
	
    public String getSDate() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        return sdf.format(getCheckouttime());
    }
    
    public static Date nextMonday(String date)throws Exception{
        
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Calendar cal = Calendar.getInstance();
        cal.setTime(sdf.parse(date));
        int week = cal.get(Calendar.DAY_OF_WEEK);
        if(week>2){
            cal.add(Calendar.DAY_OF_MONTH,-(week-2)+7);
        }else{
            cal.add(Calendar.DAY_OF_MONTH,2-week+7);
        }
        return cal.getTime();
    }

    public static Date nextMonthFirstDate(String date) throws Exception{
        
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Calendar cal = Calendar.getInstance();
        cal.setTime(sdf.parse(date));
        
//        Calendar calendar = Calendar.getInstance();
        cal.set(Calendar.DAY_OF_MONTH, 1);
        cal.add(Calendar.MONTH, 1);
        return cal.getTime();
    }

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "Order [orderid=" + orderid + ", hotelid=" + hotelid
				+ ", hotelname=" + hotelname + ", otaid=" + otaid
				+ ", otaname=" + otaname + ", hprice=" + hprice + ", oprice="
				+ oprice + ", saletype=" + saletype + ", checkouttime="
				+ checkouttime + "]";
	}

}
